/*************************************************************************
 *
 * $Id: data.h 62 2006-07-27 16:54:30Z alpov $
 * 
 *************************************************************************/         

#ifndef _DATA_H
#define _DATA_H

#define MAX_DESC_LEN        16
#define SENSOR_MAX_COUNT    16
#define MODE_MAX_COUNT      8


/* udaje ukladane lokalne do EEPROM terminalu
 */ 
typedef struct {
    unsigned char sensor_count;
    char sensors[SENSOR_MAX_COUNT][8];
    unsigned char term_addr;
    signed char rtc_deviation;
} EEDATA_STRUCT;


/* informativni udaje predavane mozkem periodicky do vsech klientu; read only pro terminal
 * pristup z mozku: STDATA-WRITE(one)
 */ 
typedef struct {
    signed int temperature[SENSOR_MAX_COUNT];
    unsigned char io_state;
    unsigned char reg_state; // FIXME
} STDATA_STRUCT;


/* udaje nastavitelne pres menu; read-write pro terminal
 * pristup z mozku: RWDATA-READ(all,one), RWDATA-WRITE(all,one)
 * pristup do mozku: RWDATA-READ(all), RWDATA-WRITE(one)
 */  
typedef struct {
    unsigned char mode;
    signed char shift;
    unsigned char shift_length;
    unsigned char sw_mode;
    unsigned long sw_datetime;
    unsigned long now;
} RWDATA_STRUCT;


extern EEDATA_STRUCT eedata;        // eeprom
extern STDATA_STRUCT stdata;        // sram
extern RWDATA_STRUCT rwdata;        // sram

//extern Mutex DataLock;

extern void ReadEEPromBlock(void *pointer_ram, void *pointer_eeprom, unsigned char n);
extern void WriteEEPromBlock(void *pointer_ram, void *pointer_eeprom, unsigned char n);

#endif
